package com.css.zfzx.sjcj.modules.hddcB3DrillProjectTable.repository;

import com.css.zfzx.sjcj.modules.hddcA1InvRgnHasMaterialTable.repository.entity.HddcA1InvrgnhasmaterialtableEntity;
import com.css.zfzx.sjcj.modules.hddcB3DrillProjectTable.repository.entity.HddcB3DrillprojecttableEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author zhangcong
 * @date 2020-11-30
 */
public interface HddcB3DrillprojecttableRepository extends JpaRepository<HddcB3DrillprojecttableEntity, String> {
    @Modifying
    @Query(nativeQuery = true,value ="update hddc_b3_drillprojecttable set qualityinspection_status=:qualityinspection_status,extends1=:extend1 where workregionid=:workregionid")
    void updateStatus(@Param("qualityinspection_status") String qualityinspection_status,@Param("extend1") String extend1,@Param("workregionid") String workregionid);
    @Modifying
    @Query(nativeQuery = true,value = "update hddc_b3_drillprojecttable set qualityinspection_status=:qualityinspection_status ,extends2=:extend2 where targetregionid=:targetregionid and is_valid=1")
    void updateStatus2(@Param("qualityinspection_status")String qualityinspection_status,@Param("extend2") String extend2,@Param("targetregionid") String targetregionid);

    @Query(nativeQuery = true,value="select w.* from hddc_b3_drillprojecttable  w where w.id=?1 and w.is_valid=1")
    HddcB3DrillprojecttableEntity findbyId(@Param("id")String id);

    @Modifying
    @Query(nativeQuery = true,value = "update hddc_b3_drillprojecttable set qualityinspection_status=:qualityinspection_status ,extends3=:extend3 where mainafsregionid=:mainafsregionid")
    void updateztqStatus(@Param("qualityinspection_status")String qualityinspection_status,@Param("extend3") String extend3,@Param("mainafsregionid") String mainafsregionid);

    @Query(nativeQuery = true,value = "select * from hddc_b3_drillprojecttable where is_valid=1 and (qualityinspection_status!=3 or qualityinspection_status is null) ")
    List<HddcB3DrillprojecttableEntity> findByAll();

    HddcB3DrillprojecttableEntity findByUuidAndIsValid(String id, String isValid);
}
